package com.gandong8.es.web.service.impl;

import com.gandong8.es.web.service.PublicService;
import com.gandong8.es.tool.core.EsDoc;
import com.gandong8.es.tool.core.EsQuery;
import com.gandong8.es.tool.service.EsService;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;
import java.util.List;

public class PublicServiceImpl implements PublicService {
    protected Class<?> indexClazz ;

    @Autowired
    EsService esService;

    @Override
    public Boolean indexCreate() {
        return esService.createIndex(indexClazz);
    }

    @Override
    public Boolean indexDelete() {
        return esService.deleteIndex(indexClazz);
    }

    @Override
    public Boolean add(EsDoc obj)  {
        return esService.addDoc(obj);
    }

    @Override
    public Boolean update(EsDoc obj)  {
        return esService.updateDoc(obj);
    }

    @Override
    public Boolean delete(EsDoc obj)  {
        return esService.delDoc(obj);
    }

    @Override
    public EsDoc get(EsDoc obj)  {
        return esService.getDoc(obj);
    }

    @Override
    public <T extends EsDoc> List<T> search(EsQuery<T> query) throws IOException {
        return esService.search(query);
    }



}
